package com.sg.service.biz.component.impl;

import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.component.req.CalculateContentAmountComReqDto;
import com.sg.dto.biz.component.req.CalculateContentAmountReqDto;
import com.sg.dto.biz.component.res.CalculateContentAmountComRespDto;
import com.sg.dto.biz.component.res.CalculateContentAmountRespDto;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class StatisticalDataServiceImpl implements com.wicket.okrcomponent.biz.service.StatisticalDataService {
    @Resource
    private RedisUtil redisUtil;
    //@Resource
    //private MCustomFieldsService mCustomFieldsService;
    @Resource
    private NbStatisticalData nbStatisticalData;

    /**
     * D2计算数据集内容条数服务(公共)[3386]
     * gen by moon at 12/2/2022, 10:21:35 PM
     */
    @Trace(operationName = "D2计算数据集内容条数服务(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public CalculateContentAmountComRespDto calculateContentAmountCom(CalculateContentAmountComReqDto reqDto) {


        CalculateContentAmountRespDto getDataCountRes_1 = null;
//步骤0: M2计算内容条数(特殊方法） - calculateContentAmount
        //ModelCode: getDataCount
        CalculateContentAmountRespDto getDataCountRes = null;
        CalculateContentAmountReqDto getDataCountReq = new CalculateContentAmountReqDto();
        if (reqDto != null) {
            getDataCountReq.setContentAmountList(reqDto.getContentAmountList());//list-field-assign//sourceId:134667_1
        }

        /*M2计算内容条数(特殊方法）[3384]  入参一个数据集，返回数据集条数 */

        getDataCountRes = nbStatisticalData.calculateContentAmount(getDataCountReq);


        getDataCountRes_1 = getDataCountRes;

        CalculateContentAmountComRespDto retData = new CalculateContentAmountComRespDto();
        if (getDataCountRes_1 != null) {
            retData.setCalcCount(getDataCountRes_1.getCalcCount());//SimpleFieldAssign//sourceId:134670_1
        }


        return retData;
    }

    //
}
